home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2006 July & August
/
PCWorld_2006-07-08_cd.bin
/
v cisle
/
acehtml
/
acehtmlfreeware.exe
/
scriptdef
/
Encrypt-Decrypt Script.sd
< prev
next >
Wrap
INI File
|
2004-06-28
|
6KB
|
217 lines
[SUBJECT]
Description=Encrypt/Decrypt your messages
ImageIndex=-1
Folder=Tools
[HEAD_TEXT]
;<!-- Cut-N-Paste JavaScript from ISN Toolbox
; Copyright 1997, Infohiway, Inc. Restricted use is hereby
; granted (commercial and personal OK) so long as this code
; is not *directly* sold and the copyright notice is buried
; somewhere deep in your HTML document. A link to our site
; http://www.infohiway.com is always appreciated of course,
; but is absolutely and positively not necessary. ;-) -->
;<script language="JavaScript">
;<!-- Hide from JS-Impaired Browsers
;/* Although the "cs" string is
; in ASCII order below, it
; can be "scrambled" if you
; wish to further complicate
; any decryption attempts. */
;bs="\\ ";
;cs=' !"#$%&';
;cs+="'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS"
;+"TUVWXYZ^[_]'abcdefghijklmnopqrstuvwxyz{|}~\t\r\n"+bs;
;cm=0;
;cm1=0;
;cflg="";
;/* Although this example has been prepared using
; a four-bit paradigm, you may elect to alter it
; to a 2-bit, 3-bit, 5-bit, etc. paradigm. For
; example, a 2 bit paradigm would look like this:
; four="00 01 10 11 ";
; fourletter="a b c d "
; and the code in the encryption and decryption
; routines below would need to be altered to
; reflect the change in bit paradigm. We've
; put comments at the appropriate places.
; Caution: don't use a space as a printing character
; in your construction of the variable "sixletter".
; Some alternates are included here for your own
; construction consideration.
; sixletter="A B C D E F G H "
; +"I J K L M N O P ";
; sixletter=". , / ' | _ ( ~ "
; +"! @ ^ * - : ; ? "; */
;sixteen="0000 0001 0010 0011 0100 0101 0110 0111 "
; +"1000 1001 1010 1011 1100 1101 1110 1111 ";
;sixletter="; . * , x ( i : "
; +"_ - ^ < > ' ~ = ";
;
;function samp(){
; // First, we grab the two strings
; ls="";
; ls1="";
; kwd=document.ex1.key.value;
; kwdpd=kwd;
; msg=document.ex1.ps.value;
; // Pad key to be long enough for message
; if (cflg==0){
; sl=msg.length;
; }
; else{
; sl=msg.length/2;
; }
; while (kwd.length<sl){
; kwd+=kwdpd;
; }
; document.ex1.ps.value="I am now converting key and message strings...";
; if (cflg!=1){
; setTimeout("samp2()",1000);
; }
; else{
; setTimeout("decryp()",1000);
; }
; }
;
;function samp2(){
; // Next, convert the 2 strings to binary
; for (var i=0;i<msg.length;i++){
; chk=kwd.charAt(i);
; cmk=cs.indexOf(chk)+32;
; chm=msg.charAt(i);
; cmm=cs.indexOf(chm)+32;
; for (var j=7;j>-1;j--){
; c=Math.pow(2,j);
; if (cmk>=c){
; cmk=cmk-c;
; ls+="1";
; }
; else{
; ls+="0";
; }
; if (cmm>=c){
; cmm=cmm-c;
; ls1+="1";
; }
; else{
; ls1+="0";
; }
; }
; }
; document.ex1.ps.value="I am now encrypting message string...";
; setTimeout("samp3()",1000);
; }
;
;function samp3(){
; // Next, convert the bits using key string
; ls2="";
; ls4="";
; for (var i=0;i<ls1.length;i++){
; ch=ls.charAt(i);
; ch1=ls1.charAt(i);
; if (ch=="0"){
; if (ch1=="0"){
; ch1="1";
; }
; else{
; ch1="0";
; }
; }
; ls2+=ch1;
; }
; /* If a different bit paradigm is
; used, alter the loop below
; accordingly. */
; for (var i=0;i<ls2.length;i=i+4){
; ls3=ls2.substring(i,i+4);
; y=sixteen.indexOf(ls3);
; ls4+=sixletter.charAt(y);
; }
; document.ex1.ps.value=ls4;
; }
;
;function decryp(){
; // Convert the keyword again
; ls="";
; for (var i=0;i<kwd.length;i++){
; chk=kwd.charAt(i);
; cmk=cs.indexOf(chk)+32;
; for (var j=7;j>-1;j--){
; c=Math.pow(2,j);
; if (cmk>=c){
; cmk=cmk-c;
; ls+="1";
; }
; else{
; ls+="0";
; }
; }
; }
; document.ex1.ps.value="I am now decrypting message string...";
; setTimeout("decryp1()",1000);
; }
;
;function decryp1(){
; /* Next, return msg from 4 bit to 8 bit.
; If a different bit paradigm is
; used, alter the loop variable below
; accordingly. */
; ls1="";
; for (var i=0;i<msg.length;i++){
; ls3=msg.charAt(i);
; y=sixletter.indexOf(ls3);
; ls1+=sixteen.substring(y,y+4);
; }
; // Next, convert the bits using key string
; ls2="";
; ls4="";
; for (var i=0;i<ls1.length;i++){
; ch=ls.charAt(i);
; ch1=ls1.charAt(i);
; if (ch=="0"){
; if (ch1=="0"){
; ch1="1";
; }
; else{
; ch1="0";
; }
; }
; ls2+=ch1;
; }
; for (var i=0;i<ls2.length;i=i+8){
; ls3=ls2.substring(i,i+8);
; y=parseInt(ls3,2);
; ls4+=cs.charAt(y-32);
; }
; document.ex1.ps.value=ls4;
; }
;
;// End Hiding -->
;</script>
[BODY_TEXT]
;<div align="center">
;<table border="0" width="500">
;<tr><td align="center"><font face="Helvetica,Arial,Geneva"><b>`Caption`</b></font><hr noshade></td></tr>
;<tr><td><font face="Helvetica,Arial,Geneva">
;<form name="ex1">
;<b>First: </b>Paste or type your key letter, key word or key phrase here:
;<br><input type="password" name="key" value="" size="84">
;<p><b>Second: </b>Paste or type your message to be encrypted here:
;<br><textarea name="ps" rows="10" cols="75" wrap="virtual"></textarea>
;<br><b>Third: </b> <input type="button" name="but" value=" Encrypt " onClick="cflg=0;samp()">
;<br><b>Fourth: </b> <input type="button" name="but1" value=" Decrypt " onClick="cflg=1;samp()"></form>
;<p>This script also supports multiple (recursive) encryption using the same or different key letters, key words or key phrases for each iteration. The encrypted message length, however, will double with each encryption.</FONT><HR NOSHADE></td></tr>
;</table>
;</div>
[`Caption`]
Kind=S
Value=A Simple Encryption App Using Bit Swapping